import { PluginFunction, VueConstructor } from 'vue';
import { PanelConst } from '../constants';
import { panel } from '../panel-global';
import {
  AppMenuContent,
  AppMenuMaterial,
  AppMenuProvider,
  SysPortletContent,
  SysPortletMaterial,
  SysPortletProvider,
} from './components';
import { TestConst } from './constants';
import { PanelData } from './panel-data';
import { PanelLayoutData } from './panel-layout-data';

export const install: PluginFunction<unknown> = (vue: VueConstructor, _config: unknown) => {
  vue.component('app-menu-content', AppMenuContent);
  vue.component('app-menu-material', AppMenuMaterial);
  vue.component('sys-portlet-content', SysPortletContent);
  vue.component('sys-portlet-material', SysPortletMaterial);

  panel.registerProvider(TestConst.PANEL_ITEM_APP_MENU, new AppMenuProvider());
  panel.registerProvider('SYSPORTLET', new SysPortletProvider());
  panel.registerProvider('APPVIEW', new SysPortletProvider());
  panel.registerProvider('RAWITEM', new SysPortletProvider());

  panel.registerDataProvider(TestConst.PANEL_ITEM_APP_MENU, (data: any): PanelData => {
    return new PanelData(data);
  });
  panel.registerDataProvider(PanelConst.LAYOUT_PANEL, (data: any): PanelData => {
    return new PanelLayoutData(data);
  });
  panel.registerDataProvider('SYSPORTLET', (data: any): PanelData => {
    return new PanelData(data);
  });
  panel.registerDataProvider('APPVIEW', (data: any): PanelData => {
    return new PanelData(data);
  });
  panel.registerDataProvider('RAWITEM', (data: any): PanelData => {
    return new PanelData(data);
  });
};

export default { install };
